/*
 * @Author: silence
 * @Date: 2023-08-18 11:57:49
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2023-08-18 14:09:08
 * @Description: 设备联网设置Item
 */
import 'package:flutter/material.dart';
import 'package:sil_base_widget_package/sil_base_widget_package.dart';

import '../../../utils/color/ColorUtils.dart';

class DeviceNetworkingItem extends StatefulWidget {
  final String? title;
  final String? leftImgPath;
  final double? leftImgWidth;
  final double? leftImgHeight;
  final Widget? middleView;
  final Widget? rightView;
  final void Function()? tapRightViewFunc;
  final String? subTitle;
  final EdgeInsetsGeometry? padding;
  final EdgeInsetsGeometry? margin;
  final int rightViewFlex;
  const DeviceNetworkingItem(
      {this.subTitle,
      this.tapRightViewFunc,
      this.title,
      this.leftImgPath,
      this.rightView,
      this.padding,
      this.rightViewFlex = 1,
      this.margin,
      this.middleView,
      this.leftImgWidth,
      this.leftImgHeight,
      super.key});

  @override
  State<DeviceNetworkingItem> createState() => _DeviceNetworkingItemState();
}

class _DeviceNetworkingItemState extends State<DeviceNetworkingItem> {
  @override
  Widget build(BuildContext context) {
    return contentView();
  }

  contentView() {
    return Container(
      margin: widget.margin ?? EdgeInsets.symmetric(horizontal: 20.w),
      decoration: BoxDecoration(
          border: Border(
              bottom: BorderSide(
                  color: ColorUtils.color_divider_line, width: 0.5.w))),
      padding: widget.padding ?? EdgeInsets.symmetric(vertical: 15.w),
      child: Container(
        child: Row(
          children: [
            /// 左侧图片
            if (widget.leftImgPath != null)
              SilImage(
                widget.leftImgPath,
                width: widget.leftImgWidth ?? 24.w,
                height: widget.leftImgHeight ?? 24.w,
                margin: EdgeInsets.only(right: 10.w),
              ),

            /// 左边标题
            Expanded(
                child: widget.middleView ??
                    SilText(
                      widget.title,
                      fontSize: 14.sp,
                      color: ColorUtils.color_font_main,
                      fontWeight: FontWeight.w500,
                      textAlign: TextAlign.left,
                      maxLines: 0,
                    )),

            // 右侧
            widget.rightView ?? Container(),
          ],
        ),
      ),
    );
  }
}
